/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.router.facade;

import info.peigen.hotpot.business.router.facade.enums.ChannelBusinessType;
import info.peigen.hotpot.business.router.facade.enums.ChannelCode;
import info.peigen.hotpot.business.router.facade.enums.ChannelCurrencyType;
import info.peigen.hotpot.common.core.domain.bank.SwiftCode;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

import static info.peigen.hotpot.common.core.enums.CountryCode.HK;


/**
 * <b>(Channel)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/9/29
 */
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class Channel {
    /** 渠道中文名 */
    String              channelName;
    /** 渠道代码 */
    ChannelCode         channelCode;
    /** 渠道[业务]类型 */
    ChannelBusinessType channelBusinessType;
    /** 渠道[币种]类型 */
    ChannelCurrencyType channelCurrencyType;
    /** 渠道[账户]属性 */
    ChannelAccount      channelAccount;

    public static Channel genChannel(ChannelCode code, ChannelBusinessType channelBusinessType, ChannelCurrencyType channelCurrencyType) {
        return Channel.builder()
                .channelCode(code)
                .channelName(code.message())
                .channelBusinessType(channelBusinessType)
                .channelCurrencyType(channelCurrencyType)
                .build();
    }

    public static Channel genChannel(ChannelCode code, ChannelBusinessType channelBusinessType) {
        return Channel.builder()
                .channelCode(code)
                .channelName(code.message())
                .channelBusinessType(channelBusinessType)
                .build();
    }

    public static Channel genReceiptChannel(ChannelCode code) {
        return Channel.builder()
                .channelCode(code)
                .channelName(code.message())
                .channelBusinessType(ChannelBusinessType.Receipt)
                .channelCurrencyType(code == ChannelCode.Weixin ? ChannelCurrencyType.Multi : ChannelCurrencyType.Local)
                .build();
    }

    private static ChannelAccount genAccount(ChannelCode code) {
        if (code == ChannelCode.Weixin) {
            return ChannelAccount.builder()
                    .provisionsAccountName("Hotpot LIMITED - CLIENT ACCOUNT")
                    .provisionsAccountNo("000827734")
                    .selfAccountName("Hotpot LIMITED")
                    .selfAccountNo("000827743")
                    .bankCountryCode(HK)
                    .address("G/F, The Center,99 Queen's Road Central, Central, Hong Kong")
                    .swiftCode(SwiftCode.create("DHBKHKHHXXX"))
                    .build();
        }
        return null;
    }
}